<?php

class Application_Model_DbTable_Comments extends Zend_Db_Table_Abstract
{

	protected $_name = 'comments';

	public function getComment($idArticle)
	{
		$idArticle  = (int)$idArticle;
		$row = $this->fetchAll('idArticle = ' . $idArticle, 'date DESC');
		if (!$row) {
			throw new Exception("Impossible de trouver le commentaire $id");
		}
		return $row;
	}

	public function addComment($user,$comment, $index)
	{
		$auth = Zend_Auth::getInstance();

		$data = array(
		'auteur' =>  $user,
		'text' => $comment,
		'idArticle' => $index
		);
		$this->insert($data);
	}
	public function updateComment($index,$indexArticle,$text)
	{
		$data = array ('text'=>$text);
			
		$this->update($data,'id= '.$index .'and idArticle = ' .$indexArticle);
			
			
	}


}

?>